# -*- coding: utf-8 -*- 
# @project : 《Atcoder》
# @Author : created by bensonrachel on 2021/8/11
# @File : TPM（step1）A. Merging Arrays.py

def TPM():
    char = []
    while(rate_a and rate_b):# 这样判断数组里面是否没有值
        if(rate_a[0] >= rate_b[0]):
            tmp = rate_b.pop(0)
            char.append(tmp)
        else:
            tmp = rate_a.pop(0)
            char.append(tmp)
    if(not rate_b):# 这样判断数组里面是否没有值
        char = char + rate_a
    else:
        char = char + rate_b
    return char
if __name__ == "__main__":
    """
    array = [] ： array ！= None（就是，就算数组里面没有值，数组也不等于None）
    """
    n,m = map(int,input().split())
    rate_a = [int(i) for i in input().split()]
    rate_b = [int(i) for i in input().split()]
    res = TPM()
    for i in res:
        print(i,end=' ')
